package org.wh1tew0lf.vframe.framework;

import java.util.Map;

import org.wh1tew0lf.vframe.framework.vframeexception.VFrameException;

public enum VDatabaseRestrictionOperator implements IDatabaseOperator {
	LESS_THAN("(##FIELD## < ##VALUE_0##)", "", false), 
	LESS_THAN_OR_EQUAL_TO("(##FIELD## <= ##VALUE_0##)", "", false), 
	EQUAL_TO("(##FIELD## = ##VALUE_0##)", "", false), 
	GREATER_THAN_OR_EQUAL_TO("(##FIELD## >= ##VALUE_0##)", "", false), 
	GREATER_THAN("(##FIELD## > ##VALUE_0##)", "", false), 
	BETWEEN("(##FIELD## BETWEEN ##VALUE_0## AND ##VALUE_1##)", "", false), 
	BEGIN_WITH("(##FIELD## LIKE ##VALUE_0## || '%')","", false), 
	END_WITH("(##FIELD## LIKE '%' || ##VALUE_0##)","", false), 
	IS("(##FIELD## = ##VALUE_0##)","", false), 
	HAVE("(##FIELD## LIKE '%' || ##VALUE_0## || '%')","", false), 
	BEGIN_WITH_IGNORE_CASES("(UPPER(##FIELD##) LIKE UPPER(##VALUE_0##) || '%')","", false), 
	END_WITH_IGNORE_CASES("(UPPER(##FIELD##) LIKE '%' || UPPER(##VALUE_0##))","", false), 
	IS_IGNORE_CASES("(UPPER(##FIELD##) = UPPER(##VALUE_0##))","", false), 
	HAVE_IGNORE_CASES("(UPPER(##FIELD##) LIKE '%' || UPPER(##VALUE_0##) || '%')","", false), 
	ORACLE_TEXT_CONTAINS("(CONTAINS(##FIELD##, ##VALUE_0##, ##VALUE_1##) > 0)", "", false);

	private String formatText;
	private String seperator;
	private boolean rawValueData;

	private VDatabaseRestrictionOperator(String formatText, String seperator, boolean rawValueData) {
		this.formatText = formatText;
		this.seperator = seperator;
		this.rawValueData = rawValueData;
	}

	@Override
	public String toString(boolean rawValueData, String fieldName, Map<String, String> fieldNameMap,
			IDatabaseRestriction... restrictions) throws VFrameException {
		String realFormatText = rawValueData ? "##VALUE_0##" : this.formatText;
		return AbstractDatabaseOperator.toString(this.rawValueData, realFormatText, seperator,
				fieldName, fieldNameMap, restrictions);
	}
}
